//
//  @ Project : Galaxy Star Trading System
//  @ File Name : ParkedOrderManager.h
//  @ Date : 2014/9/5
//  @ Author : 
//
//
#if !defined(_PARKEDORDER_MANANGER_H)
#define _PARKEDORDER_MANANGER_H

namespace GSTrader
{
	namespace TradeStrategy
	{
		enum ParkedOrderGetType
		{
			pstAllOrder,
			pstParkedOrder,
			pstConditionOrder,
			pstSendedOrder,
		};

		class CFramework;
		class TRADE_STRATEGY_API CParkedOrderManager
		{
		public:
			CParkedOrderManager(CFramework* pFramework);
			virtual ~CParkedOrderManager();

			void GetLocalConditionOrder(int nInstrumentId, vector<CParkedOrder>& vParkedOrder);
			bool AddNewParkedOrder(COrder* pOrder, int nParkedOrderType, int nPriceType, COrderCondition* pCondition);
			void AddParkedOrder(CParkedOrder* pParkedOrder);
			bool DeleteAllSendedParkedOrder();
			bool SendOrder(CParkedOrder* pParkedOrder, CTradeProvider* pTradeProvider = NULL);
			void RefreshLocal();
			void RefreshTimer();
			void NotifyToParent(CParkedOrder* pParkedOrder);
			bool DeleteConditonOrder(int nInstrumentId, bool bBuy);
			void OnExchangeStatusChange(CExchangeStatus* pExchangeStatus);
			bool DeleteOrder(CParkedOrder* pOrder);
			void DeleteAllOrder();
			string GetString(CParkedOrder* pOrder);

			void GetParkedOrderByType(int nType, vector<CParkedOrder>& vParkedOrder, int nProviderId = -1, int nInstrumentId = -1);

		private:
			COrderCondition m_orderCondition;
			
			atomic<int> m_nNextId;
			CFramework* m_pFramework;
			vector<CParkedOrder*> m_vParkedOrder;
			vector<CParkedOrder*> m_vLocalConditionOrder;
			vector<CParkedOrder*> m_vLocalTimeOrder;
			vector<CParkedOrder*> m_vExchangeStatusOrder;
		};
	}
}

#endif // _PARKEDORDER_MANANGER_H
